home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Oberon⁄F™ 1.2 / Preinstalled version / Manuals / DTC (.txt) < prev    next >
Encoding:
Oberon Document  |  1996-04-03  |  27.1 KB  |  438 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. HostPictures.StdViewDesc
  17. c}}}}}}
  18. hxxxxxx
  19. opppppp
  20. vSSttjj
  21. xhhhhhh
  22. z]]llhh
  23. ~cccccc
  24. IIjjbb
  25. ^^^^^^
  26. XXXXXX
  27. EE``WW
  28. TTTTTT
  29. >>\\TT
  30. PPPPPP
  31. OOOOOO
  32. MMNNMM
  33. oo::PP
  34. IIIIII
  35. AAAAAA
  36. 33GGAA
  37. ::::::
  38. 22::77
  39. ##??77
  40. 555555
  41. 222222
  42. ------
  43. ))))))
  44. $$$$$$
  45.         ,,""
  46. #DKss
  47. syXD;
  48. #.b`U
  49. Y``8%
  50. CIIHC
  51. $$!Vc_Z
  52. wrCN#
  53. Helvetica
  54. Helvetica
  55. Helvetica
  56. Helvetica
  57. Helvetica
  58.       FINALIST
  59. Direct-To-COM Oberon Compiler
  60. The Direct-To-COM (DTC) compiler is an Oberon compiler that supports Microsoft's Component Object Model (COM) binary interface standard. The "SaferOLE" technology adds automatic memory management to OLE objects. The seamless integration of COM into a dynamic, object-oriented language is a world premiere. The DTC compiler relieves programmers from cumbersome and error-prone manual memory management. Programs become more reliable and maintainable. COM Objects implemented with the DTC compiler can be used from any other language, and COM objects implemented in any language can be used from Oberon.
  61. COM is the foundation of OLE. Reference counting errors are the number one source of errors when programming to the OLE interfaces. In contrast to C and C++, programmers using the DTC Oberon compiler do not need to worry about reference counting anymore. The compiler automatically calls an object's AddRef and Release methods where necessary. When a COM object is no longer used, it is automatically removed from memory.
  62. With the DTC compiler, reference counting errors simply will not occur. COM objects can no longer produce memory leaks or dangling pointers. Debugging time can be cut back dramatically and applications reach the market earlier, with fewer defects. The tool can easily save weeks of debugging time, thus paying for itself in a short time.
  63. In DTC Oberon, objects are declared and implemented in a superset of the Oberon language (see code sample below). The compiler implements a COM object's AddRef and Release methods automatically.
  64. The compiler has built-in LONGCHAR and HUGEINT data types to support Unicode characters and 64-bit integers. It supports full 64-bit arithmetic.
  65. The compiler is delivered with the Oberon/F integrated development environment. The debugger lets you inspect components and objects on a symbolic level. It uses hypertext links to visualize pointers, letting you browse through dynamic memory just like you surf on the Web. 
  66. Features
  67. - Typesafe COM programming with automatic memory management
  68. - Compiler calls object
  69. s AddRef and Release methods automatically whenever necessary
  70. - Compiler implements AddRef and Release methods of new objects automatically
  71. - Default implementation of QueryInterface
  72. - Unicode and 64-bit integer arithmetic support built into language
  73. - out parameter classes
  74. - NIL-compatible VAR parameters for efficient interfacing to C and C++
  75. - Optimized debugger for symbolic inspection of objects
  76. Relation Between DTC Oberon Compiler and Oberon/F
  77. The DTC compiler is targeted at programmers who need to develop at the COM level. Typically, these programmers develop new OLE components, e.g. a new OLE control (OCX). They want full control over all COM features and no overhead. In turn they are accepting that they have to know all the intricacies of COM and the OLE APIs, that their code is non-portable, and that they have to give up some of the safety of an all-Oberon component. The DTC compiler retains as much of Oberon's safety as is possible with direct COM programming.
  78. Most Oberon/F programmers never need to program at the COM level. For this reason, Oberon/F and the DTC compiler are independent product lines, although the DTC compiler actually uses a version of Oberon/F as its integrated development environment.
  79. Oberon-COM Code Sample
  80. The following example defines and implements the EnumX interface for rectangles. The type IEnumRECT defines the IEnumRECT interface. This type cannot be instantiated. The interface is implemented in the class EnumRECT.
  81. Note, that both the AddRef and Release methods as well as the QueryInterface methods are implemented by the compiler.
  82. The  C++ code sample for exactly the same example is given below.
  83. MODULE ComEnumRect;
  84.     (* adapted from EnumRect sample in "Inside OLE", 2nd ed. *)
  85.     (* 12.2.96 Oberon microsystems inc. *)
  86.     IMPORT COM, WinOle;
  87.     CONST rects = 15;
  88.     TYPE
  89.         PtrIEnumRECT* = POINTER TO IEnumRECT;
  90.         IEnumRECT* =
  91.             RECORD ["{00021140-0000-0000-C000-000000000046}"] (WinOle.IUnknown)
  92.             END;
  93.         PtrEnumRECT = POINTER TO EnumRECT;
  94.         EnumRECT = RECORD (IEnumRECT)
  95.             cur: LONGINT;
  96.             data: ARRAY rects OF WinOle.RECT;
  97.         END;
  98.     (* ---------- abstract interface methods ---------- *)
  99.     (* QueryInterface, AddRef, Release inherited from WInOle.IUnknown *)
  100.     PROCEDURE (this: PtrIEnumRECT) Next* (num: LONGINT;
  101.                                         VAR [out] elem: ARRAY [untagged] OF WinOle.RECT;
  102.                                         VAR [nil] fetched: LONGINT): WinOle.RESULT;
  103.     END Next;
  104.     PROCEDURE (this: PtrIEnumRECT) Skip* (num: LONGINT): WinOle.RESULT;
  105.     END Skip;
  106.     PROCEDURE (this: PtrIEnumRECT) Reset* (): WinOle.RESULT;
  107.     END Reset;
  108.     PROCEDURE (this: PtrIEnumRECT) Clone* (VAR [out] enum: PtrIEnumRECT): WinOle.RESULT;
  109.     END Clone;
  110.     (* ---------- interface implementation ---------- *)
  111.     (* use default QueryInterface implementation *)
  112.     (* AddRef & Release implemented implicitly by the compiler *)
  113.     PROCEDURE (this: PtrEnumRECT) Next (num: LONGINT;
  114.                                         VAR [out] elem: ARRAY [untagged] OF WinOle.RECT;
  115.                                         VAR [nil] fetched: LONGINT): WinOle.RESULT;
  116.         VAR n: LONGINT;
  117.     BEGIN
  118.         n := 0;
  119.         IF VALID(fetched) THEN fetched := 0
  120.         ELSIF num # 1 THEN RETURN WinOle.S_FALSE
  121.         END;
  122.         IF this.cur < rects THEN
  123.             WHILE (this.cur < rects) & (num > 0) DO
  124.                 elem[n] := this.data[this.cur];
  125.                 INC(this.cur); INC(n); DEC(num)
  126.             END;
  127.             IF VALID(fetched) THEN fetched := n END;
  128.             RETURN WinOle.S_OK
  129.         END;
  130.         RETURN WinOle.S_FALSE
  131.     END Next;
  132.     PROCEDURE (this: PtrEnumRECT) Skip (num: LONGINT): WinOle.RESULT;
  133.     BEGIN
  134.         IF this.cur + num < rects THEN
  135.             INC(this.cur, num); RETURN WinOle.S_OK
  136.         ELSE RETURN WinOle.S_FALSE
  137.         END
  138.     END Skip;
  139.     PROCEDURE (this: PtrEnumRECT) Reset (): WinOle.RESULT;
  140.     BEGIN
  141.         this.cur := 0; RETURN WinOle.S_OK
  142.     END Reset;
  143.     PROCEDURE (this: PtrEnumRECT) Clone (VAR [out] enum: PtrIEnumRECT): WinOle.RESULT;
  144.         VAR new: PtrEnumRECT;
  145.     BEGIN
  146.         NEW(new);
  147.         IF new # NIL THEN
  148.             new.cur := this.cur;
  149.             new.data := this.data;
  150.             enum := new;
  151.             RETURN WinOle.S_OK
  152.         ELSE RETURN WinOle.E_OUTOFMEMORY
  153.         END
  154.     END Clone;
  155.     PROCEDURE CreateRectEnumerator* (VAR enum: PtrIEnumRECT);
  156.         VAR new: PtrEnumRECT; i: INTEGER;
  157.     BEGIN
  158.         NEW(new);
  159.         IF new # NIL THEN
  160.             new.cur := 0; i := 0;
  161.             WHILE i < rects DO
  162.                 new.data[i].left := i;
  163.                 new.data[i].top := i * 2;
  164.                 new.data[i].right := i * 3;
  165.                 new.data[i].bottom := i * 4;
  166.                 INC(i)
  167.             END;
  168.             enum := new
  169.         END
  170.     END CreateRectEnumerator;
  171. END ComEnumRect.
  172. C++ Code Sample
  173. ============================================================
  174.  * IENUM0.H
  175.  * Definition of an IEnumRECT interface as an example of OLE
  176.  * interfaces as they appear in C and C++.
  177.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  178.  * Kraig Brockschmidt, Microsoft
  179.  * Internet  :  kraigb@microsoft.com
  180.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  181. #ifndef _IENUM0_H_
  182. #define _IENUM0_H_
  183. //C++ Definition of an interface.
  184. #ifdef __cplusplus
  185. typedef struct IEnumRECT IEnumRECT;
  186. typedef IEnumRECT *PENUMRECT;
  187. //This is the interface:  a struct of pure virtual functions.
  188. struct IEnumRECT
  189.     {
  190.     STDMETHOD(QueryInterface)(REFIID, PPVOID)=0;
  191.     STDMETHOD_(ULONG,AddRef)(void)=0;
  192.     STDMETHOD_(ULONG,Release)(void)=0;
  193.     STDMETHOD(Next)(DWORD, LPRECT, LPDWORD)=0;
  194.     STDMETHOD(Skip)(DWORD)=0;
  195.     STDMETHOD(Reset)(void)=0;
  196.     STDMETHOD(Clone)(PENUMRECT *)=0;
  197.     };
  198. #else   //!__cplusplus
  199.  [ ... details ommitted ... ]
  200. #endif //_IENUM0_H_
  201. ============================================================
  202.  * ENUMRECT.H
  203.  * C/C++ Enumerator Demonstrtion Chapter 2
  204.  * Definitions, classes, and prototypes
  205.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  206.  * Kraig Brockschmidt, Microsoft
  207.  * Internet  :  kraigb@microsoft.com
  208.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  209. #ifndef _ENUMRECT_H_
  210. #define _ENUMRECT_H_
  211.  [ ... details omitted ... ]
  212. //Number of rects that objects with IEnumRECT support (for demo)
  213. #define CRECTS      15
  214.   [ ... details omitted ... ]
  215.  * The class definition for an object that singly implements
  216.  * IEnumRECT in C++.
  217. class CEnumRect : public IEnumRECT
  218.     {
  219.     private:
  220.         DWORD           m_cRef;         //Reference count
  221.         DWORD           m_iCur;         //Current enum position
  222.         RECT            m_rgrc[CRECTS]; //RECTS we enumerate
  223.     public:
  224.         CEnumRect(void);
  225.         ~CEnumRect(void);
  226.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  227.         STDMETHODIMP_(ULONG) AddRef(void);
  228.         STDMETHODIMP_(ULONG) Release(void);
  229.         //IEnumRECT members
  230.         STDMETHODIMP Next(ULONG, LPRECT, ULONG *);
  231.         STDMETHODIMP Skip(ULONG);
  232.         STDMETHODIMP Reset(void);
  233.         STDMETHODIMP Clone(PENUMRECT *);
  234.     };
  235. typedef CEnumRect *PCEnumRect;
  236. //Function that creates one of these objects
  237. BOOL CreateRECTEnumeratorCPP(PENUMRECT *);
  238.  [ ... details omitted ... ]
  239. #endif //_ENUMRECT_H_
  240. ==================================================================
  241.  * ENUMCPP.CPP
  242.  * Enumerator in C++ Chapter 2
  243.  * Implements the CEnumRECT class
  244.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  245.  * Kraig Brockschmidt, Microsoft
  246.  * Internet  :  kraigb@microsoft.com
  247.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  248. #include "enumrect.h"
  249.  * CreateRECTEnumeratorCPP
  250.  * Purpose:
  251.  *  Creates an enumerator object returning an IEnumRECT interface.
  252.  * Parameters:
  253.  *  ppEnum          PENUMRECT * in which to return the
  254.  *                  interface pointer on the created object.
  255.  * Return Value:
  256.  *  BOOL            TRUE if the function is successful,
  257.  *                  FALSE otherwise.
  258. BOOL CreateRECTEnumeratorCPP(PENUMRECT *ppEnum)
  259.     {
  260.     PCEnumRect  pER;
  261.     HRESULT     hr;
  262.     if (NULL==ppEnum)
  263.         return FALSE;
  264.     //Create the object
  265.     pER=new CEnumRect();
  266.     if (NULL==pER)
  267.         return FALSE;
  268.     //Get the interface, which calls AddRef
  269.     hr=pER->QueryInterface(IID_IEnumRECT, (void **)ppEnum);
  270.     return SUCCEEDED(hr);
  271.     }
  272.  * CEnumRect::CEnumRect
  273.  * CEnumRect::~CEnumRect
  274.  * Constructor Parameters:
  275.  *  None
  276. CEnumRect::CEnumRect(void)
  277.     {
  278.     UINT        i;
  279.     //Initialize the array of rectangles
  280.     for (i=0; i < CRECTS; i++)
  281.         SetRect(&m_rgrc[i], i, i*2, i*3, i*4);
  282.     //Ref counts always start at zero
  283.     m_cRef=0;
  284.     //Current pointer is the first element.
  285.     m_iCur=0;
  286.     return;
  287.     }
  288. CEnumRect::~CEnumRect(void)
  289.     {
  290.     return;
  291.     }
  292.  * CEnumRect::QueryInterface
  293.  * Purpose:
  294.  *  Manages interfaces for the CEnumRect object.
  295.  * Parameters:
  296.  *  riid            REFIID of the interface to return.
  297.  *  ppv             PPVOID in which to return the pointer.
  298.  * Return Value:
  299.  *  HRESULT         NOERROR if successful, E_NOINTERFACE if the
  300.  *                  interface is not supported.
  301. STDMETHODIMP CEnumRect::QueryInterface(REFIID riid, PPVOID ppv)
  302.     {
  303.     //Always NULL the out-parameters
  304.     *ppv=NULL;
  305.     /*
  306.      * No explicit typecast necessary since we singly derive
  307.      * from IEnumRECT.
  308.      */
  309.     if (IID_IUnknown==riid || IID_IEnumRECT==riid)
  310.         *ppv=this;
  311.     if (NULL==*ppv)
  312.         return ResultFromScode(E_NOINTERFACE);
  313.     //AddRef any interface we'll return.
  314.     ((LPUNKNOWN)*ppv)->AddRef();
  315.     return NOERROR;
  316.     }
  317.  * CEnumRect::AddRef
  318.  * Purpose:
  319.  *  Increments the reference count on the object.
  320.  * Parameters:
  321.  *  None
  322.  * Return Value:
  323.  *  ULONG           New reference count.
  324. STDMETHODIMP_(ULONG) CEnumRect::AddRef(void)
  325.     {
  326.     return ++m_cRef;
  327.     }
  328.  * CEnumRect::Release
  329.  * Purpose:
  330.  *  Indicates that someone on whose behalf we once AddRef'd has
  331.  *  finished with the object.  We decrement our reference count
  332.  *  and if zero, we delete the object.
  333.  * Parameters:
  334.  *  None
  335.  * Return Value:
  336.  *  ULONG           Current reference count after decrement.  If
  337.  *                  this returns zero then the interface is no
  338.  *                  longer valid.
  339. STDMETHODIMP_(ULONG) CEnumRect::Release(void)
  340.     {
  341.     if (0!=--m_cRef)
  342.         return m_cRef;
  343.     delete this;
  344.     return 0;
  345.     }
  346.  * CEnumRect::Next
  347.  * Purpose:
  348.  *  Returns the next rectangle in the enumerator.
  349.  * Parameters:
  350.  *  cRect           DWORD number of RECTs to return
  351.  *  prc             LPRECT in which to store the returned RECT.
  352.  *  pdwRects        LPDWORD in which to store the number of
  353.  *                  structs returned.
  354.  * Return Value:
  355.  *  HRESULT         NOERROR if successful, S_FALSE otherwise,
  356. STDMETHODIMP CEnumRect::Next(DWORD cRect, LPRECT prc, LPDWORD pdwRects)
  357.     {
  358.     DWORD           cRectReturn=0L;
  359.     if (NULL==pdwRects)
  360.         {
  361.         if (1L!=cRect)
  362.             return ResultFromScode(S_FALSE);
  363.         }
  364.     else
  365.         *pdwRects=0L;
  366.     if (NULL==prc || (m_iCur >= CRECTS))
  367.         return ResultFromScode(S_FALSE);
  368.     while (m_iCur < CRECTS && cRect > 0)
  369.         {
  370.         *prc++=m_rgrc[m_iCur++];
  371.         cRectReturn++;
  372.         cRect--;
  373.         }
  374.     if (NULL!=pdwRects)
  375.         *pdwRects=cRectReturn;
  376.     return NOERROR;
  377.     }
  378.  * CEnumRect::Skip
  379.  * Purpose:
  380.  *  Skips the next n elements in the enumerator.
  381.  * Parameters:
  382.  *  cSkip           DWORD number of elements to skip.
  383.  * Return Value:
  384.  *  HRESULT         NOERROR if successful, S_FALSE if we could not
  385.  *                  skip the requested number.
  386. STDMETHODIMP CEnumRect::Skip(DWORD cSkip)
  387.     {
  388.     if ((m_iCur+cSkip) >= CRECTS)
  389.         return ResultFromScode(S_FALSE);
  390.     m_iCur+=cSkip;
  391.     return NOERROR;
  392.     }
  393.  * CEnumRect::Reset
  394.  * Purpose:
  395.  *  Resets the current element in the enumerator to zero.
  396.  * Parameters:
  397.  *  None
  398.  * Return Value:
  399.  *  HRESULT         NOERROR
  400. STDMETHODIMP CEnumRect::Reset(void)
  401.     {
  402.     m_iCur=0;
  403.     return NOERROR;
  404.     }
  405.  * CImpEnumRECT::Clone
  406.  * Purpose:
  407.  *  Creates a copy enumerator.
  408.  * Parameters:
  409.  *  ppEnum          PENUMRECT * in which to store the clone.
  410.  * Return Value:
  411.  *  HRESULT         NOERROR if successful, error code otherwise.
  412. STDMETHODIMP CEnumRect::Clone(PENUMRECT *ppEnum)
  413.     {
  414.     if (CreateRECTEnumeratorCPP(ppEnum))
  415.         {
  416.         /*
  417.          * Copy the current index.  The typecast is safe because
  418.          * we know that the IEnumRECT from the creation function
  419.          * is really a CEnumRect pointer.
  420.          */
  421.         ((PCEnumRect)(*ppEnum))->m_iCur=m_iCur;
  422.         return NOERROR;
  423.         }
  424.     return ResultFromScode(E_OUTOFMEMORY);
  425.     }
  426. -----------------------------------------------------------------------------
  427. TextControllers.StdCtrlDesc
  428. TextControllers.ControllerDesc
  429. Containers.ControllerDesc
  430. Controllers.ControllerDesc
  431. TextRulers.StdRulerDesc
  432. TextRulers.RulerDesc
  433. TextRulers.StdStyleDesc
  434. TextRulers.StyleDesc
  435. TextRulers.AttributesDesc
  436. Helvetica
  437. Documents.ControllerDesc
  438.